package com.whc.gulimall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.whc.common.valid.AddGroup;
import com.whc.common.valid.ListValue;
import com.whc.common.valid.UpdateGroup;
import com.whc.common.valid.UpdateStatusGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * 品牌
 *
 * @author wanghaochen
 * @email angaoen@outlook.com
 * @date 2022-03-05 00:18:53
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 品牌id
     */
    @TableId
    @Null(message = "新增无需设置id", groups = {AddGroup.class})
    @NotNull(message = "修改必须指定id", groups = {UpdateGroup.class})
    private Long brandId;

    /**
     * 品牌名
     */
    @NotBlank(message = "品牌名不得为空", groups = {AddGroup.class})
    private String name;

    /**
     * 品牌logo地址
     */
    @NotEmpty(message = "logo不得为空", groups = {AddGroup.class})
    @URL(message = "logo必须是一个合法的地址", groups = {AddGroup.class, UpdateGroup.class})
    private String logo;

    /**
     * 介绍
     */
    @NotBlank(message = "描述不得为空", groups = {AddGroup.class})
    private String descript;

    /**
     * 显示状态[1-不显示；0-显示]
     */
    @NotNull(message = "显示状态不得为空", groups = {AddGroup.class, UpdateStatusGroup.class})
    @ListValue(vals = {0, 1}, message = "请按规定填写", groups = {AddGroup.class, UpdateStatusGroup.class})
    private Integer showStatus;

    /**
     * 检索首字母
     */
    @NotBlank(message = "检索首字母不得为空", groups = {AddGroup.class})
    @Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母必须是一个字母", groups = {AddGroup.class, UpdateGroup.class})
    private String firstLetter;

    /**
     * 排序
     */
    @NotNull(message = "排序不得为空", groups = {AddGroup.class})
    @Min(value = 0L, message = "排序必须大于等于0", groups = {AddGroup.class, UpdateGroup.class})
    private Integer sort;
}
